<?php
namespace app\controllers;
use srvs\UserService;
use yii\web\Controller;
use app\models\LoginForm;
use app\models\ContactForm;
use srvs\web\Curl;

class TestController extends Controller
{
    public function actionCache()
    {
        $key = 'people';
        $value = json_encode(array('name' => 'ball', 'age' => 'male'));
        $expire = 10;
        \Yii::$app->cache->set($key, $value, $expire);
        $result = \Yii::$app->cache->get($key);
        echo $result;
        \Yii::$app->cache->delete($key);
    }

    public function  actionCurl(){
        $curl=new Curl();
        $result=$curl->get("http://www.baidu.com");
        var_dump($result);
    }

    public function actionEmail(){
        $to_email="9570710@qq.com";
        $from_email="mianshibiji@163.com";
        $from_name="mianshibiji_admin";
        $title="title";
        $content="Hello World<span style='color:red'>content</span>";
        \Yii::$app->mailer->compose()
            ->setTo($to_email)
            ->setFrom([$from_email => $from_name])
            ->setSubject($title)
            ->setHtmlBody($content)
            ->send();
    }
}